//  this library.
import 'package:flutter/material.dart';
import 'package:hktk_app/model/subject/paper_model.dart';
// import 'package:hktk_app/pages/subject/paper_detail_page.dart';
import 'package:hktk_app/util/font_util.dart';

import 'package:hktk_app/util/view_util.dart';

/// 真题对应的item
class TrueQuestionWidget extends StatelessWidget {
  /// 对应的数据
  final PaperModel paper;

  /// 栏目底
  final String columnId;

  /// 考试对应下标
  final int index;

  const TrueQuestionWidget({
    super.key,
    required this.paper,
    required this.columnId,
    required this.index,
  });

  /// 左边标题显示方法
  get _leftShow => SizedBox(
        width: 510,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Text(
              paper.name!,
              style: FontUtil.fontBlack1(28, fontWeight: FontWeight.w500),
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
            ),
            _bottomTips,
          ],
        ),
      );

  /// 底部提示
  get _bottomTips => Row(
        children: [
          _leftTips,
          hiSpace(width: 19),
          _line,
          hiSpace(width: 19),
          // showDifficulty(num: 2),
          _qNum,
          hiSpace(width: 19),
          _line,
          hiSpace(width: 19),
          _rightTips,
        ],
      );

  /// 左边历年真题提示
  get _leftTips => Text(
        paper.paperType!.desc,
        style: FontUtil.fontGrey2(24),
      );

  /// 竖线分割
  get _line => Container(
        height: 22,
        decoration: BoxDecoration(
          border: Border(
            right: BorderSide(color: colorGrey5, width: 2),
          ),
        ),
      );

  /// 右边提示，多少人做过
  // get _rightTips => Row(
  //       children: [
  //         Icon(
  //           Icons.person,
  //           size: 24,
  //           color: colorGrey5,
  //         ),
  //         Text(
  //           paper.stuCount?.toString() ?? "0",
  //           style: FontUtil.fontGrey5(24),
  //         ),
  //       ],
  //     );
  get _rightTips => Text(
        "${paper.stuCount ?? 0} 人做过",
        style: FontUtil.fontGrey5(24),
      );

  /// 显示总题数
  get _qNum => Text(
        "总题数 ${paper.qcount ?? 0}",
        style: FontUtil.fontGrey2(24),
      );

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: 82,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          _leftShow,
          _rightButton(context),
        ],
      ),
    );
  }

  /// 右边按钮显示
  _rightButton(BuildContext context) {
    return GestureDetector(
      onTap: () {
        _onTapFun(context);
      },
      child: Container(
        width: 136,
        height: 60,
        decoration: BoxDecoration(
            color: colorBlue2,
            borderRadius: BorderRadius.all(Radius.circular(29))),
        child: Center(
          child: Text(
            "做题",
            style: FontUtil.fontBlue1(24),
          ),
        ),
      ),
    );
  }

  /// 做题点击方法
  void _onTapFun(BuildContext context) {
    if (true) {
      // 免费，跳转做题页面
      Navigator.pushNamed(context, "/paper-detail", arguments: {
        "id": paper.id!,
        "columnId": columnId,
        "recordId": paper.recordId,
        "index": index,
      });
    }
  }
}
